/**
 * Mock配置文件
 **/
 
// 引入mockjs
import Mock from "mockjs"

// user 列表
let userList = [
  {
    id: 1,
    jobNo: "001",
    name: "jxh",
    email: "jxh@qq.com",
    brief: "你好，我叫江小海",
    avatar: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "position": "admin",
    dept: "技术部",
    reson: "申请理由测试"
  },
  {
    id: 2,
    jobNo: "002",
    name: "jdh",
    email: "jdh@qq.com",
    brief: "你好，我叫江大海",
    avatar: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
    "position": "staff",
    dept: "设计部",
    reson: "申请理由测试1"
  }
]

// WG 列表
let wgList = [
  {
    id: 1,
    name: "测试1",
    description: "描述1",
    schedule: "测试1",
    creator: "jxh",
    member: "jxh,jdh",
    date: "2022-08-21",
    focus: false
  },
  {
    id: 2,
    name: "测试2",
    description: "描述2",
    schedule: "测试2",
    creator: "jxh",
    member: "jxh,jdh",
    date: "2022-08-20",
    focus: true
  },
  {
    id: 3,
    name: "测试3",
    description: "描述3",
    schedule: "测试3",
    creator: "jxh",
    member: "jxh,jdh",
    date: "2022-08-15",
    focus: false
  },
  {
    id: 4,
    name: "测试4",
    description: "描述4",
    schedule: "测试4",
    creator: "jxh",
    member: "jxh,jdh",
    date: "2022-08-05",
    focus: true
  }
]

// 注册接口
Mock.mock("http://127.0.0.1:5173/user/add", "post", (params) => {
  return {
    code: 200,
    msg: "请求成功"
  }
})

Mock.mock("http://127.0.0.1:5173/loginIn", "post", (params) => {
  let paramsBody = JSON.parse(params.body)
  let user = userList.find(item => item.name == paramsBody.name)
  return {
    code: user ? 200 : 404,
    msg: user ? "登录成功" : "用户不存在",
    data: {
      user,
      token: "hasljdl;dskc;las.dashjldlkas.gkashj"
    }
  }
})

Mock.mock("http://127.0.0.1:5173/logOut", "get", () => {
  return {
    code: 200,
    msg: "请求成功"
  }
})


// 获取wg列表
Mock.mock("http://127.0.0.1:5173/wginfo/findAll", "get", () => {
  return {
    code: 200,
    msg: "请求成功",
    data: wgList,
    count: wgList.length
  }
})

// 获取wg详细信息
Mock.mock("http://127.0.0.1:5173/wginfo/findById/1", "get", () => {
  let wgInfo = wgList.find(item => item.id == 1)
  return {
    code: 200,
    msg: "请求成功",
    data: wgInfo,
  }
})

// 获取wg人员列表
Mock.mock("http://127.0.0.1:5173/user/queryUserAll/", "get", () => {
  return {
    code: 200,
    msg: "请求成功",
    data: userList,
  }
})